# Maintainer: Alexander F. Rødseth <xyproto@archlinux.org>
# Contributor: Lukas Fleischer <lfleischer@archlinux.org>
# Contributor: Stefan Husmann <stefan-husmann@t-online.de>
# Contributor: Simon Lipp <sloonz+aur@gmail.com>

pkgname=fop
pkgver=2.9
pkgrel=1
pkgdesc='XSL-FO to PDF formatter'
arch=(any)
url='https://xmlgraphics.apache.org/fop/'
license=(APACHE)
depends=(java-avalon-framework 'java-batik=1.17' java-commons-io java-commons-logging java-xmlgraphics-commons)
makedepends=(apache-ant java-environment maven)
source=("https://dlcdn.apache.org/xmlgraphics/$pkgname/source/$pkgname-$pkgver-src.tar.gz"
        fop.conf)
b2sums=('6ab265ddfb1c07b9266687930af21ac4653438800772da836dbceb14de126333dcff50c2cea1352ad77988ec7f7a3d4eef91341983edc13684abf2531634eb0a'
        '928ced5f2591d2537829d74ae94c6f59e1be2f12eddf44e2f7fe5fd06606e94a5911396d6ef8596137449524c9d0d13ef8896bc4fb5e58096bd9948708879857')
backup=(etc/fop.conf)

prepare() {
  cd $pkgname-$pkgver/$pkgname
  cp -f "$srcdir/fop.conf" fop_modified.conf
  pacman -Ql java-batik | grep \.jar | sed 's/java-batik /CLASSPATH="$CLASSPATH:/g;s/$/"/g' >> fop_modified.conf
}

build() {
  cd $pkgname-$pkgver
  ant -f $pkgname/build.xml package
}

package() {
  cd $pkgname-$pkgver/$pkgname
  install -Dm755 $pkgname "$pkgdir/usr/bin/$pkgname"
  install -Dm644 build/fop.jar "$pkgdir/usr/share/java/fop/fop.jar"
  install -Dm644 fop_modified.conf "$pkgdir/etc/fop.conf"
}
